// Lang_31 [interfaces].nova // The application class. class InterfacesApp { // Application class's "main" function. public static void main( String[] args ) { // Create a new object using a concrete class and assign to an interface reference. IAbstract a = new ConcreteClass( ); // Call a virtual method using the abstract class reference. a.method0( ); // Call a virtual method using the abstract class reference. a.method1( ); // It is not possible to instantiate a new object using an abstract class. // Uncomment this line to enable the error. // AbstractClass abstractClass = new AbstractClass( ); } } // Declare an interface. interface IAbstract { // Declare an implicit abstract method. public IAbstract method0( ); // The "abstract" keyword is optional in an interface definition. public abstract void method1( ); } // Declare an interface. interface IAbstract2 : IAbstract { // Redefine "method0" with a covariant return type. public IAbstract2 method0( ); } // Concrete class that implements the defined interface. class ConcreteClass : IAbstract, IAbstract2 { // Declare an instance method. public ConcreteClass method0( ) { Stream.writeLine( "ConcreteClass.method0( ) - called" ); return this; } // Declare an instance method. public void method1( ) { Stream.writeLine( "ConcreteClass.method1( ) - called" ); } }